//
//  ACEConfirmBottomView.m
//  ACE
//
//  Created by zhangtao on 2018/8/14.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEConfirmBottomView.h"

@implementation ACEConfirmBottomView
{
    UILabel *moneyLab;
    UILabel *markMoneyLab;
}
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(frame.size.width-100, 0, 100, frame.size.height)];
        [button setBackgroundColor:MAIN_COLOR()];
        [button setTitle:@"确定" forState:UIControlStateNormal];
        [self addSubview:button];
        
        moneyLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(button.frame)-100, 0, 100, frame.size.height)];
        moneyLab.textColor = deepGreen;
        moneyLab.font = [UIFont systemFontOfSize:20];
        moneyLab.text = @"$200";
        [self addSubview:moneyLab];
        
        
        markMoneyLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMinX(moneyLab.frame)-60, 0, 100, frame.size.height)];
        //        markMoneyLab.textColor = deepGreen;
        markMoneyLab.font = [UIFont systemFontOfSize:14];
        markMoneyLab.text = @"总金额:";
        [self addSubview:markMoneyLab];
        
        UILabel *topLine = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, 1)];
        topLine.backgroundColor = RGB(244, 244, 244, 1);
        [self addSubview:topLine];
    }
    return self;
}

-(void)setTotalMoney:(NSString *)totalMoney{
    if (!totalMoney) {
        return;
    }
    _totalMoney = totalMoney;
    
    moneyLab.text = [@"$" stringByAppendingString:totalMoney];
    
    dispatch_async(dispatch_get_main_queue(), ^{
        CGRect frame = moneyLab.frame;
        [moneyLab sizeToFit];
        CGRect newFrame = moneyLab.frame;
        moneyLab.frame = CGRectMake(self.frame.size.width-100-newFrame.size.width-10, 0, newFrame.size.width, self.frame.size.height);
        markMoneyLab.frame = CGRectMake(CGRectGetMinX(moneyLab.frame)-60, 0, 100, frame.size.height);
    });
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end

